package com.gitee.wsl.ext.bitcode

import com.gitee.wsl.ext.string.EMPTY

/** Returns a hexadecimal string representation of this [Byte] value. */
 fun Byte.toHexadecimalString(): String = (toInt() and 0xFF).toString(16).padStart(2, '0')

/** Returns a hexadecimal string representation of this [ByteArray] value. */
 fun ByteArray.toHexadecimalString(): String = joinToString(String.EMPTY) { it.toHexadecimalString() }

/** Returns a hexadecimal string representation of this [Int] value. */
 fun Int.toHexadecimalString(): String = toString(16)

/** Returns a hexadecimal string representation of this [Long] value. */
 fun Long.toHexadecimalString(): String = toString(16)

/** Returns a hexadecimal string representation of this [UByte] value. */
 fun UByte.toHexadecimalString(): String = toString(16).padStart(2, '0')

/** Returns a hexadecimal string representation of this [UByteArray] value. */
@OptIn(ExperimentalUnsignedTypes::class)
 fun UByteArray.toHexadecimalString(): String = joinToString(String.EMPTY) { it.toHexadecimalString() }

/** Returns a hexadecimal string representation of this [UInt] value. */
 fun UInt.toHexadecimalString(): String = toString(16)

/** Returns a hexadecimal string representation of this [ULong] value. */
 fun ULong.toHexadecimalString(): String = toString(16)